package com.ymatou.livevideo.testcase;

import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.livevideo.parameter.RecLiveNotifyBean;
import com.ymatou.livevideo.parameter.ReplayNotifyBean;
import com.ymatou.livevideo.parameter.Trancode;
import com.ymatou.livevideo.parameter.TrancodeInPut;
import com.ymatou.livevideo.parameter.TrancodeOutPut;
import com.ymatou.livevideo.service.ReplayNotifyCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.CounterCallService;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.business.service.ProductManagerCallServiceV2;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.livetv.ProductVideo;
import com.ymttest.database.model.livetv.ProductVideoExplain;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.RunTestsV2;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

import org.junit.*;
import org.junit.experimental.categories.Category;

import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
/**
*录制文件事件处理
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ReplayNotify{
	private static ReplayNotifyBean replaynotifyBean;
	private static ReplayNotifyCall replaynotifyCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("录制文件事件处理");
	}

	@Before
	public void caseUp() {
		replaynotifyBean=new ReplayNotifyBean();
		replaynotifyCall=new ReplayNotifyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(replaynotifyCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_001() {
		Logger.start(true,"录制文件事件处理成功");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
		//	verifyPushStream(liveroom.getId());
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			replaynotifyCall.setData(replaynotifyBean);
			Map mock=new HashMap();
//			mock:mock-enable
			mock.put("mock", "mock-enable");
			mock.put("mockId-1", TestDataManager.getRandomUUID().toString());
			mock.put("mockApi-1", "livevideo-processMediaByProcedure-Normal");
			PayGateWayCallService.addMock(replaynotifyCall, mock);
			
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			Logger.debug(m);
			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			Logger.verifyEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
			Logger.verifyEquals(replaynotifyBean.getData().getFileId(), m.get("FileId").toString(), "验证FileId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_002() {
		Logger.start(true,"EventType错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			replaynotifyBean.setEventType("err");
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("500", replaynotifyCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_003() {
		Logger.start(true,"data.errorcode错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			replaynotifyBean.getData().setErrCode(-1);
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			//错误无数据
//			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
//			Logger.verifyNotEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_004() {
		Logger.start(true,"data.FileId错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			replaynotifyBean.getData().setFileId("err");
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("400", replaynotifyCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_005() {
		Logger.start(true,"data.processTaskList.TaskType错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			Trancode sendto=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			sendto.setTaskType("err");
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			Logger.debug(m);
			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			Logger.verifyNotEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_006() {
		Logger.start(true,"data.processTaskList.errorcode错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			Trancode sendto=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			sendto.setErrCode(-1);
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			Logger.debug(m);
			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			Logger.verifyNotEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_007() {
		Logger.start(true,"data.processTaskList.Status错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			Trancode sendto=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			sendto.setStatus("Failed");
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			Logger.debug(m);
			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			Logger.verifyNotEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_008() {
		Logger.start(true,"data.processTaskList.Definition错误失败");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
			Trancode sendto=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			sendto.setStatus("Failed");
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			Logger.debug(m);
			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			Logger.verifyNotEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_009() {
		Logger.start(true,"录制文件事件处理成功,output.size为long型-http://jira.ymatou.cn:8080/browse/JIRACONN-30554");
		try {
			CreateSellerLiveBean createsellerliveBean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom liveroom = LiveRoomCallService.CreateSellerLive(createsellerliveBean);
			LiveRoomCallService.UpdateLiveTimeToStart(liveroom.getId());
			Logger.comment("先推流再接受第三方通知");
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(liveroom.getId(), 100);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
		//	verifyPushStream(liveroom.getId());
			replaynotifyBean = LiveRoomCallService.initReplayNotifyBean(liveroom.getId(),recivenotifyBean.getFile_id());
//			Logger.debug(FormatUtil.beanToGSONString(replaynotifyBean));
			((Trancode) replaynotifyBean.getData().getProcessTaskList().get(0)).getOutput().setSize(Integer.MAX_VALUE+1l);;
//			Logger.debug(FormatUtil.beanToGSONString(replaynotifyBean));
			replaynotifyCall.setData(replaynotifyBean);
			
			Map mock=new HashMap();
//			mock:mock-enable
			mock.put("mock", "mock-enable");
			mock.put("mockId-1", TestDataManager.getRandomUUID().toString());
			mock.put("mockApi-1", "livevideo-processMediaByProcedure-Normal");
			PayGateWayCallService.addMock(replaynotifyCall, mock);
			
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			Map m=new LiveRoomWapper().selectLivereplayById(liveroom.getId().toString());
			Logger.debug(m);
			Trancode to=(Trancode) replaynotifyBean.getData().getProcessTaskList().get(0);
			Logger.verifyEquals(to.getOutput().getUrl(), m.get("ReplayBQUrl"), "验证ReplayBQUrl");
			Logger.verifyEquals(replaynotifyBean.getData().getFileId(), m.get("FileId").toString(), "验证FileId");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_010() {
		Logger.start(true,"录制商品讲解视频成功");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			Date starttime = new Date(now.getTime() + 5000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(clive);
			LiveRoomCallService.AddProductsToLive(livedto.getId(), sellerId, productId);
			Thread.sleep(5000);
			LiveRoomCallService.SellerLiveOnline(livedto.getId(), livedto.getUserId());
			String taskId = LiveRoomCallService.CreateProductVideo(livedto.getId(), sellerId, productId);
			LiveRoomCallService.StopProductVideo(livedto.getId(), productId);
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(livedto.getId(), 100);
			recivenotifyBean.setTask_id(taskId);
			String fileId = TestDataManager.getRandomNum(15);
			recivenotifyBean.setFile_id(fileId);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			LiveRoomWapper liveroomwapper=new LiveRoomWapper();
			ProductVideo pv = liveroomwapper.selectProductvideo(productId);
			Logger.verifyEquals(pv.getUserId(),sellerId , "验证UserId");
			Logger.verifyEquals(pv.getVideoUrl(),recivenotifyBean.getVideo_url() , "验证VideoUrl");
			Logger.verifyEquals(pv.getDuration()+"",recivenotifyBean.getDuration() , "验证Duration");
			Logger.verifyEquals(pv.getVideoSize()+"",recivenotifyBean.getFile_size() , "验证VideoSize");
			Logger.verifyEquals(pv.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pv.getFileId(),recivenotifyBean.getFile_id() , "验证FileId");
			Logger.comment("pv1:"+FormatUtil.beanToGSONString(pv));
			ProductVideoExplain pve = liveroomwapper.selectProductvideoExplain(productId);
			Logger.verifyEquals(pve.getUserId(),sellerId , "验证UserId");
			Logger.verifyEquals(pve.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pve.getLiveId(),livedto.getId() , "验证LiveId");
			Logger.verifyEquals(pve.getExplainStatus(),5, "验证ExplainStatus");
			
			replaynotifyBean=LiveRoomCallService.initAskProductReplayNotifyBean(livedto.getId(), fileId);
			
			Map mock=new HashMap();
//			mock:mock-enable
			mock.put("mock", "mock-enable");
			mock.put("mockId-1", TestDataManager.getRandomUUID().toString());
			mock.put("mockApi-1", "livevideo-processMediaByProcedure-Normal");
			PayGateWayCallService.addMock(replaynotifyCall, mock);
			
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			
			pv = liveroomwapper.selectProductvideo(productId);
			Logger.verifyEquals(pv.getUserId(),sellerId , "验证UserId");
			
			Logger.verifyEquals(pv.getDuration()+"",recivenotifyBean.getDuration() , "验证Duration");
			Logger.verifyEquals(pv.getVideoSize()+"",recivenotifyBean.getFile_size() , "验证VideoSize");
			Logger.verifyEquals(pv.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pv.getFileId(),recivenotifyBean.getFile_id() , "验证FileId");
			String vurl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("Transcode");}).findAny().get()).getOutput().getUrl();
			Logger.verifyEquals(pv.getVideoUrl(),vurl , "验证VideoUrl");
			String gurl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("AnimatedGraphics");}).findAny().get()).getOutput().getUrl();
			Logger.verifyEquals(pv.getGifUrl(),gurl , "验证gurl");
			String curl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("CoverBySnapshot");}).findAny().get()).getOutput().getImageUrl();
			Logger.verifyEquals(pv.getCoverUrl(),curl , "验证curl");
			Logger.comment("pv2:"+FormatUtil.beanToGSONString(pv));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_011() {
		Logger.start(true,"录制商品讲解视频成功-taskid支持long");
		try {
			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			Date starttime = new Date(now.getTime() + 5000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(clive);
			LiveRoomCallService.AddProductsToLive(livedto.getId(), sellerId, productId);
			Thread.sleep(5000);
			LiveRoomCallService.SellerLiveOnline(livedto.getId(), livedto.getUserId());
			String taskId = LiveRoomCallService.CreateProductVideo(livedto.getId(), sellerId, productId,TestDataManager.getRandomNum(11));
			LiveRoomCallService.StopProductVideo(livedto.getId(), productId);
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(livedto.getId(), 100);
			recivenotifyBean.setTask_id(taskId);
			String fileId = TestDataManager.getRandomNum(15);
			recivenotifyBean.setFile_id(fileId);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			LiveRoomWapper liveroomwapper=new LiveRoomWapper();
			ProductVideo pv = liveroomwapper.selectProductvideo(productId);
			Logger.verifyEquals(pv.getUserId(),sellerId , "验证UserId");
			Logger.verifyEquals(pv.getVideoUrl(),recivenotifyBean.getVideo_url() , "验证VideoUrl");
			Logger.verifyEquals(pv.getDuration()+"",recivenotifyBean.getDuration() , "验证Duration");
			Logger.verifyEquals(pv.getVideoSize()+"",recivenotifyBean.getFile_size() , "验证VideoSize");
			Logger.verifyEquals(pv.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pv.getFileId(),recivenotifyBean.getFile_id() , "验证FileId");
			Logger.comment("pv1:"+FormatUtil.beanToGSONString(pv));
			ProductVideoExplain pve = liveroomwapper.selectProductvideoExplain(productId);
			Logger.verifyEquals(pve.getUserId(),sellerId , "验证UserId");
			Logger.verifyEquals(pve.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pve.getLiveId(),livedto.getId() , "验证LiveId");
			Logger.verifyEquals(pve.getExplainStatus(),5, "验证ExplainStatus");
			
			replaynotifyBean=LiveRoomCallService.initAskProductReplayNotifyBean(livedto.getId(), fileId);
			
			Map mock=new HashMap();
//			mock:mock-enable
			mock.put("mock", "mock-enable");
			mock.put("mockId-1", TestDataManager.getRandomUUID().toString());
			mock.put("mockApi-1", "livevideo-processMediaByProcedure-Normal");
			PayGateWayCallService.addMock(replaynotifyCall, mock);
			
			replaynotifyCall.setData(replaynotifyBean);
			replaynotifyCall.callService();			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			
			pv = liveroomwapper.selectProductvideo(productId);
			Logger.verifyEquals(pv.getUserId(),sellerId , "验证UserId");
			
			Logger.verifyEquals(pv.getDuration()+"",recivenotifyBean.getDuration() , "验证Duration");
			Logger.verifyEquals(pv.getVideoSize()+"",recivenotifyBean.getFile_size() , "验证VideoSize");
			Logger.verifyEquals(pv.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pv.getFileId(),recivenotifyBean.getFile_id() , "验证FileId");
			String vurl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("Transcode");}).findAny().get()).getOutput().getUrl();
			Logger.verifyEquals(pv.getVideoUrl(),vurl , "验证VideoUrl");
			String gurl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("AnimatedGraphics");}).findAny().get()).getOutput().getUrl();
			Logger.verifyEquals(pv.getGifUrl(),gurl , "验证gurl");
			String curl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("CoverBySnapshot");}).findAny().get()).getOutput().getImageUrl();
			Logger.verifyEquals(pv.getCoverUrl(),curl , "验证curl");
			Logger.comment("pv2:"+FormatUtil.beanToGSONString(pv));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ReplayNotify_012() {
		Logger.start(true,"录制直播事件处理成功/计数器+1");
		try {

			int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV2.addNewProduct(addpro).get("Data").getAsJsonObject().get("ProductId").getAsString();
			CreateSellerLiveBean clive = LiveRoomCallService.initCreatesellerliveBean(sellerId);
			Date now = YMTDateUtil.getDate();
			Date starttime = new Date(now.getTime() + 5000);
			Date endtime = new Date(now.getTime() + 200 * 60 * 1000);
			clive.getLiveDto().setStartTime(YMTDateUtil.getFormatTime(starttime, YMTDateUtil.YMDHMS));
			
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(clive);
			
			Thread.sleep(5000);
			LiveRoomCallService.AddProductsToLive(livedto.getId(), sellerId, productId);
			Thread.sleep(3000);
			LiveRoomCallService.SellerLiveOnline(livedto.getId(), livedto.getUserId());
			String taskId = LiveRoomCallService.CreateProductVideo(livedto.getId(), sellerId, productId);
			LiveRoomCallService.StopProductVideo(livedto.getId(), productId);
			RecLiveNotifyBean recivenotifyBean = LiveRoomCallService.initRecLiveNotifyBean(livedto.getId(), 100);
			recivenotifyBean.setTask_id(taskId);
			String fileId = TestDataManager.getRandomNum(15);
			recivenotifyBean.setFile_id(fileId);
			LiveRoomCallService.LiveNotify(recivenotifyBean);
			LiveRoomWapper liveroomwapper=new LiveRoomWapper();
			ProductVideo pv = liveroomwapper.selectProductvideo(productId);
			Logger.verifyEquals(pv.getUserId(),sellerId , "验证UserId");
			Logger.verifyEquals(pv.getVideoUrl(),recivenotifyBean.getVideo_url() , "验证VideoUrl");
			Logger.verifyEquals(pv.getDuration()+"",recivenotifyBean.getDuration() , "验证Duration");
			Logger.verifyEquals(pv.getVideoSize()+"",recivenotifyBean.getFile_size() , "验证VideoSize");
			Logger.verifyEquals(pv.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pv.getFileId(),recivenotifyBean.getFile_id() , "验证FileId");
			Logger.comment("pv1:"+FormatUtil.beanToGSONString(pv));
			ProductVideoExplain pve = liveroomwapper.selectProductvideoExplain(productId);
			Logger.verifyEquals(pve.getUserId(),sellerId , "验证UserId");
			Logger.verifyEquals(pve.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pve.getLiveId(),livedto.getId() , "验证LiveId");
			Logger.verifyEquals(pve.getExplainStatus(),5, "验证ExplainStatus");
			
			replaynotifyBean=LiveRoomCallService.initAskProductReplayNotifyBean(livedto.getId(), fileId);
			
			Map mock=new HashMap();
//			mock:mock-enable
			mock.put("mock", "mock-enable");
			mock.put("mockId-1", TestDataManager.getRandomUUID().toString());
			mock.put("mockApi-1", "livevideo-processMediaByProcedure-Normal");
			PayGateWayCallService.addMock(replaynotifyCall, mock);
			
			replaynotifyCall.setData(replaynotifyBean);
			
			Integer counter = CounterCallService.getSingleValueByLiveId(livedto.getId());
			replaynotifyCall.callService();	
			Integer counter1 = CounterCallService.getSingleValueByLiveId(livedto.getId());
			Logger.verifyEquals(counter+1, counter1, "添加商品之后，计数器+1");	
			
			Logger.verifyEquals("0", replaynotifyCall.getString("code"), "验证code");
			
			pv = liveroomwapper.selectProductvideo(productId);
			Logger.verifyEquals(pv.getUserId(),sellerId , "验证UserId");
			
			Logger.verifyEquals(pv.getDuration()+"",recivenotifyBean.getDuration() , "验证Duration");
			Logger.verifyEquals(pv.getVideoSize()+"",recivenotifyBean.getFile_size() , "验证VideoSize");
			Logger.verifyEquals(pv.getTaskId()+"",taskId , "验证TaskId");
			Logger.verifyEquals(pv.getFileId(),recivenotifyBean.getFile_id() , "验证FileId");
			String vurl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("Transcode");}).findAny().get()).getOutput().getUrl();
			Logger.verifyEquals(pv.getVideoUrl(),vurl , "验证VideoUrl");
			String gurl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("AnimatedGraphics");}).findAny().get()).getOutput().getUrl();
			Logger.verifyEquals(pv.getGifUrl(),gurl , "验证gurl");
			String curl=((Trancode)replaynotifyBean.getData().getProcessTaskList().stream().filter(p->{return ((Trancode)p).getTaskType().equals("CoverBySnapshot");}).findAny().get()).getOutput().getImageUrl();
			Logger.verifyEquals(pv.getCoverUrl(),curl , "验证curl");
			Logger.comment("pv2:"+FormatUtil.beanToGSONString(pv));
		
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
}